package com.lin.staticProxyMode.staticProxyMode.demo2;

/**
 * 代理角色<br>
 *      假设需要增加新功能, 在每个方法执行前打印使用了的方法名
 */
public class UserProxy implements UserService {
    private UserService userService;

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @Override
    public void add() {
        log("add");
        userService.add();
    }

    @Override
    public void delete() {
        log("delete");
        userService.delete();
    }

    @Override
    public void update() {
        log("update");
        userService.update();
    }

    @Override
    public void query() {
        log("query");
        userService.query();
    }

    // 扩展方法
    public void log(String msg) {
        System.out.println("使用了" + msg + "方法");
    }
}
